package myjava.objects_rock;

public class Root {

   public static void main(String[] args) {
   
      // A lot of stuff in java is an object :)
      // all this stuff inherit from the class Object
      
      // ANY object you can think of is an object! I know it's silly but let's mention it anyway
      
      // an array
      String[] arrayOfStr = {"yo", "mate", "howzit", "?"};
      System.out.println(arrayOfStr instanceof Object);
   
      // a string
      String str = "fuck off!";
      System.out.println(str instanceof Object);
      
      // BUT an int is not and instanceof blows up!
      int x = 3;
      // System.out.println(x instanceof Object);      
      
      // Although you can write shit like
      System.out.println(new Integer(1) instanceof Object);
      
      // # >>> interesting methods inherited from Object
           
      Ball myBall1 = new Ball(2); 
      Ball myBall2 = new Ball(2);
      
      // riferimento alla classe instanziatrice
      Class c = myBall1.getClass();
      
      // Class e' una classe molto cool che ha (tra gli altri) questi 3 metodi
      
      // # ritorna il nome della classe
      String name = c.getName();

      // # ritorna un riferimetno alla superclass
      Class sup = c.getSuperclass();
      String nameSup = sup.getName();      
      System.out.println(name + " | " + nameSup);

      // # compara 2 oggetti
      // if it's not defined for a (user) class, it behaves like == (which just checks the pointer in memory)
      // usually you override it in user defined classes
      System.out.println(myBall1.equals(myBall2));
   }
}